package com.example.strategy.factory;

import com.example.strategy.dto.PayEnum;
import com.example.strategy.service.PayStrategy;
import com.example.strategy.util.SpringContextUtil;

/**
 * @author xwj
 * @date 2021/4/28 17:32
 * description:
 */
public class PayStrategyFactory {
    /**
     * 通过渠道码获取支付策略具体实现类
     * */
    public static PayStrategy getPayStrategy(String channel){
        PayEnum payEnum = PayEnum.findPayEnumBychannel(channel);
        if(payEnum == null){
            return null;
        }
        return SpringContextUtil.getBean(payEnum.getBeanName(),PayStrategy.class);
    }
}
